package com.rdc.dictionary.util;

import android.content.Context;
import android.net.ConnectivityManager;

/**
 * @author Soul Mate
 * @file 文件名
 * @brief 检查网络是否可用
 */

public class NetworkUtil
{
//	/**
//	 * 判断网络是否可用
//	 */
//	public static boolean isMobileDataEnable(Context context)
//	{
//		ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
//		boolean isMobileDataEnable = false;
//		isMobileDataEnable = manager.getActiveNetworkInfo().isConnectedOrConnecting();
//		return isMobileDataEnable;
//	}

	/**
	 * 判断网络是否可用
	 */
	public static boolean isMobileDataEnable(Context context)
	{
		ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

		//无网络时为null
		if(manager.getActiveNetworkInfo()!=null)
		return true;
		else{
			return false;
		}
	}

}
